package com.hsmw.api.controller.forman;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hsmw.api.config.jwt.CurrentHsmwUserUtils;
import com.hsmw.api.config.jwt.LoginUser;
import com.hsmw.api.mapper.HsmwForcemanMedalMapper;
import com.hsmw.api.service.HsmwForcemanMedalService;
import com.hsmw.common.base.BasePage;
import com.htn.common.core.base.DataResponse;
import com.htn.common.core.constant.CommonConstants;
import com.htn.common.core.utils.StringUtils;
import com.hsmw.domain.HsmwComplain;
import com.hsmw.domain.HsmwForcemanMedal;
import com.hsmw.domain.HsmwUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.hsmw.common.base.BaseController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 工长勋章 前端控制器
 * </p>
 *
 * @author tjy
 * @since 2021-08-06
 */
@Api(tags = "工长勋章")
@RestController
@RequestMapping("/hsmw/medal")
public class HsmwForcemanMedalController extends BaseController<HsmwForcemanMedalService, HsmwForcemanMedal> {

    @Autowired
    private CurrentHsmwUserUtils currentHsmwUserUtils;

    @Autowired
    private HsmwForcemanMedalMapper hsmwForcemanMedalMapper;




    @ApiOperation(value = "查询工长勋章信息",notes = "查询工长勋章信息",produces = "application/json")
    @PostMapping("/findMedalInfoById")
    public DataResponse findComplainList(){

        LoginUser user = currentHsmwUserUtils.getCurrentUserInfo();
        if(user != null && StringUtils.isNotEmpty(user.getId())){
            HsmwForcemanMedal hsmwForcemanMedals = hsmwForcemanMedalMapper.selectOne(new LambdaQueryWrapper<HsmwForcemanMedal>().eq(HsmwForcemanMedal::getUserId, user.getId()));
            if(StringUtils.isNull(hsmwForcemanMedals)){
                hsmwForcemanMedals= new HsmwForcemanMedal();
            }
            return new DataResponse(CommonConstants.ResponseStatus.SUCCESS,hsmwForcemanMedals);
        }else {
            return new DataResponse(CommonConstants.ResponseStatus.SUCCESS,"没有信息");
        }
    }

}

